﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AutoFillCenter
{
    class SkypeAutoFill : AutoFill
    {
        public override bool Fill(String username, String password)
        {
            int id = DllLoader.FindWindow("TLoginForm", "Skype");
            
            int control = DllLoader.FindWindowEx(id, 0, "TLoginControl", null);
            
            
            int usernameField = DllLoader.FindWindowEx(control, 0, "TAccessibleComboBox", null);
            if (usernameField != 0)
            {
                int passwordField = DllLoader.FindWindowEx(control, 0, "TAccessibleEdit", null);
                DllLoader.SendMessage(usernameField, DllLoader.WM_SETTEXT, 0, username);
                DllLoader.SendMessage(passwordField, DllLoader.WM_SETTEXT, 0, password);
            }
                        
            bool foreground = DllLoader.SetForegroundWindow(control);                    
            

            if (foreground && IS_AUTO_SUBMIT)
            {
                SendKeys.SendWait("{ENTER}");
            }                         
            return true;
        }

    }
}
